<!--内容开始-->
<section class="content">
    <div class="search">
        <form class="form-inline" action="{:url('index')}" data-pjax>
            <input type="text" class="form-control" name="keyword" placeholder="标题" value="{$keyword}">
            <input type="text" class="form-control" name="dateran" autocomplete="off" placeholder="选择日期"
                   value="{$dateran}">
            <input class="btn btn-flat btn-primary" type="submit" value="搜索">
            <a class="btn btn-flat btn-primary m_10" href="{:url('index')}">显示全部</a>
            <input class="btn btn-flat btn-warning m_10 select_del" type="button" value="批量删除">
            <a class="btn btn-flat btn-success m_10 f_r" href='{:url('add')}'><i class="fa fa-plus m-r-10"></i>添 加</a>
        </form>
    </div>
    <!--数据表开始-->
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <!-- /.box-header -->
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-bordered table-hover">
                            <tr>
                                <th class="t_c"><input type="checkbox" id="check"></th>
                                <th class="t_c">编号</th>
                                <th class="t_c">标题</th>
                                <th class="t_c">调用</th>
                                <th class="t_c">链接</th>
                                <th class="t_c">图片</th>
                                <th class="t_c">备注</th>
                                <th class="t_c">添加时间</th>
                                <th class="t_c">修改时间</th>
                                <th class="t_c">排序</th>
                                <th class="t_c">状态</th>
                                <th class="t_c">操作</th>
                            </tr>
                            {volist name='list' id='list' empty="$empty"}
                            <tr>
                                <td class="t_c"><input type="checkbox" name="key[]" value="{$list.id}"></td>
                                <td class="t_c">{$list.id}</td>
                                <td class="t_c">{$list.title}</td>
                                <td class="t_c">{$list.name}</td>
                                <td class="t_c">{$list.url}</td>
                                <td class="t_c"><img class="image_preview"
                                                     src="{$list.image?$list.image:'/static/admin/images/nopic.png'}">
                                </td>
                                <td class="t_c">{$list.description}</td>
                                <th class="t_c">{$list.create_time|date="Y-m-d H:i:s"}</th>
                                <th class="t_c">{$list.update_time|date="Y-m-d H:i:s"}</th>
                                <td class="t_c">
                                    <input class="form-control input-sm w_40 m_auto changeSort" type="text"
                                           value="{$list.sort}" data-id="{$list.id}">
                                </td>
                                <td class="t_c">
                                    {if $list.status==1}
                                    <a class="state state_ok" data-id="{$list.id}"><i
                                            class="fa fa-fw fa-check-square"></i></a>
                                    {else}
                                    <a class="state state_no" data-id="{$list.id}"><i
                                            class="fa fa-fw fa-check-square"></i></a>
                                    {/if}
                                </td>
                                <td class="t_c">
                                    <a class="btn btn-flat btn-info btn-xs" href="{:url('edit',['id'=>$list.id])}">
                                        <i class="fa fa-edit"></i> 编辑
                                    </a>
                                    <a class="btn btn-flat btn-warning btn-xs list_del" data-id="{$list.id}">
                                        <i class="fa fa-trash-o"></i> 删除
                                    </a>
                                </td>
                            </tr>
                            {/volist}
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer clearfix page">
                        {$page|raw}
                        <!---->
                        {$pageSize|raw}
                        <!---->
                    </div>
                </div>
                <!-- /.box -->
            </div>
        </div>
    </div>
    <!--数据表结束-->
</section>
<!--内容结束-->

<script>
    //排序
    $(".changeSort").blur(function () {
        var url = "{:url('sort')}";
        var id = $(this).data("id");
        var sort = $(this).val();
        changeSort(url, id, sort);
    })

    //设置状态
    $(".state").click(function () {
        var url = "{:url('state')}";
        var id = $(this).data("id");
        changeState(url, id);
    })

    //删除
    $(".list_del").click(function () {
        var url = "{:url('del')}";
        var id = $(this).data("id");
        delOne(url, id)
    })

    //批量删除
    $(".select_del").click(function () {
        var url = "{:url('selectDel')}";
        delSelect(url);
    })

    //显示数量
    $(".page_size").change(function () {
        var page_size = $(this).val();
        var url = "{:url('index',['keyword'=>$keyword,'page_size'=>'pagesize'])}";
        url = url.replace("pagesize", page_size);
        pjaxReplace(url);
    });
</script>
